    
$(document).ready(function() {		
    $("#changesubject").change(function(){        
        window.location = $("#changesubject").val();
    });
})

function doSow(level_id, sub_id){
    if(sub_id != ''){
        $.ajax({
            type: 'post',
            url: SITE_URL + '/sow/doSow',
            data: 'level_id='+level_id+'&sub_id='+sub_id,
            success:function(data){
                $(document).unbind('change');
                $('#the_content').html(data);
                $(document).bind('change');                
            }
        });  
    }else{
        $.ajax({
            type: 'post',
            url: SITE_URL + '/sow/doSow',
            data: 'level_id='+level_id,
            success:function(data){
                $(document).unbind('change');
                $('#the_content').html(data);
                $(document).bind('change');
            }
        });
    }
}

function doSowByYear(){    
    data = $('#changesubject').val();    
    $.ajax({
        type: 'post',
        url: SITE_URL + '/sow/doSow',
        data: data,
        success:function(data){
            $(document).unbind('change');
            $('#the_content').html(data);
            $(document).bind('change');
                
        }
    });  
}
function load_sow(level_id, sub_id, sub_title){
    
	var url = 'sow/load_sow';
	
    $("#the_content").html('');
    $("#the_waiting").html('<img src = "../images/spinner.gif" />');
    $.post(url, {
        level_id:level_id,
        sub_id:sub_id,
        sub_title:sub_title
    }, function(data) {
        $("#the_waiting").html('');
        $("#the_content").html(data).fadeIn();
    }, "html");
}
function printPartOfPage(elementId)
{
//    var printContent = document.getElementById(elementId);
//    var windowUrl = 'about:blank';
//    var uniqueName = new Date();
//    var windowName = 'Print' + uniqueName.getTime();
//    var printWindow = window.open(windowUrl, windowName, 'left=50,top=50,width=500,height=500');
//
//    //printWindow.document.write('<link rel="stylesheet" type="text/css" href="http://blossom.jackwoo.com/imis/css/print_style.css" />');
//    printWindow.document.write(printContent.innerHTML);
//    //printWindow.document.close();
//    printWindow.focus();
//    printWindow.print();
//    printWindow.close();
    
    var printContent = document.getElementById(elementId);
    var windowUrl = 'about:blank';
    var uniqueName = new Date();
    var windowName = 'Print' + uniqueName.getTime();
    var printWindow = window.open(windowUrl, windowName, 'left=50,top=50,width=500,height=500');

    printWindow.document.write('<link rel="stylesheet" type="text/css" href="http://blossom.jackwoo.com/imis/css/print_style.css" />');
    printWindow.document.write(printContent.innerHTML);
    printWindow.document.close();
    printWindow.focus();
    printWindow.print();
    printWindow.close();
}

